package com.telchina.common.mq.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * RabbitConfig
 *
 * @author haozhen
 * @version 1.0
 * @since 2023/3/1
 */
@Configuration
public class RabbitConfig {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Bean
    public TopicExchange topicExchange() {
        TopicExchange topicExchange = new TopicExchange("amq.topic");
        return topicExchange;
    }

    @Bean
    public Queue topicQueue() {
        Queue queue = new Queue("topicqueue");
        return queue;
    }

    //binding将交换机和相应队列连起来
    @Bean
    public Binding bindingtopic1() {
        Binding binding = BindingBuilder.bind(topicQueue()).to(topicExchange()).with(".test");//binding key
        return binding;
    }


}
